package collection;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class SortString {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("安静强");
        list.add("张三");
        list.add("我爱java");
        list.add("努力学习,天天向上");
        list.add("大家好,我叫王二麻子");
        System.out.println("list中的默认排序是:"+list);

        Collections.sort(list, new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                //return o1.length()-o2.length();
                return  o2.length()-o1.length();
            }
        });
        //Collections.sort(list);
        System.out.println("list排序后的是:"+list);

    }
}
